<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="cn.edu.nju.ws.aquila.query.Datasource,java.util.ArrayList,java.util.HashMap,java.util.HashSet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Identify datasource</title>
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<link rel="stylesheet" type="text/css" href="css/identify_datasource.css" />
<link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui-1.8.16.custom.css" />
<script type="text/javascript" src="script/jquery.js"></script>
<script type="text/javascript" src="script/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="script/identify_datasource.js"></script>
</head>
<body>
		<div id="wrapper">
			<div id="top">
				<div id="user">
					welcome,<%=session.getAttribute("user")%>
				</div>
				<div id="navigation-bar"><a href='main_datasource.jsp' class="nav-title">Datasource</a><a href='main_relation.jsp' class="nav-title">Relation</a><a href='main_query.jsp' class="nav-title">Query</a><a href='logout' class="nav-title">Logout</a></div>
				<div class="mspacing"></div>
				<div  class="operation">
					Identify a new datasource
				</div>
			</div>
			<div class="mspacingLittle"></div>
			<div id="main">
				<div id="content-main">
					<div class="relative">
						<p class="title">Datasource</p>
						<div id="datasource"></div>
						<div id="source-func">
							<div id="search-datasource" class="relative"><a href="#">Select</a></div>
							<div id="input-datasource"><a href="#">Add</a></div>
							<div id="remove-datasource"><a href="#">Remove</a></div>
						</div>

						<div>
							<p class="title">Tags <span class="addTagOp"><a href="#">Add Tag</a></span></p>
							<div id="tagsList"></div>
						</div>
						<div>
							<p class="title">Description</p>
							<textarea id="description" name="description"></textarea>
						</div>
						<br/>
						<input type="button" value="ok" class="submitIdentify" onclick="checkEmpty()"/>
					</div>
					<br/>
				</div>
			</div>
		</div>
		<div class="hidden">
			<div id="add-source">
				<p>Select existing datasource</p>
				<div>
				<select id="datasourceList" multiple="multiple" size="10">
					 <%
					    String user = (String)session.getAttribute("user");
					    ArrayList<Integer> constructedDatasets =  Datasource.getDsIdByAuthor(user);
					    for(int dsId:constructedDatasets){
					    	ArrayList<String> tags = Datasource.getDsTags(dsId,user);
					  %>				
					<option mtype="tag" datatypeid="<%=dsId%>"><%=tags.get(0) %></option>
					<%} %>
					 <%
					    ArrayList<Integer> importedDatasets =  Datasource.getImportedDsIdByUser(user);
					    for(int dsId:importedDatasets){
					    	ArrayList<String> tags = Datasource.getDsTags(dsId,user);
					  %>				
					<option mtype="tag" datatypeid="<%=dsId%>"><%=tags.get(0) %></option>
					<%} %>					
		 		</select>
			  </div>
				<button id="select-ok">ok</button>		
				<button id="add-close">close</button>
			</div>
     <div id="dialog-form" title="Add a new tag" style="padding:20px">
		  <label for="tagName">Name</label>
		  <input type="text" name="tagName" id="tagName" maxlength="20"/>
     </div>
			<div id="link-source">
				<p>Input URI</p>
				<span>URI:</span><input type="text" value="" id="inputURI"/><br />
				<button type="button" id="inputURIButton">ok</button>
				<button type="button" class="close">close</button>
			</div>
		</div>
	</body>
</body>
</html>